﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace Common
{
    public class ConfigHelper
    {
        /// <summary>
        /// 根据key获得Value值
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static String GetValue(String key) {
            String config = ConfigurationManager.AppSettings[key].ToString().Trim();
            return config;
        }
        /// <summary>
        /// 根据key修改vlaue
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        public static void SetValue(string key,string value) {
            ConfigurationManager.AppSettings.Set(key,value);
        }
        /// <summary>
        /// 添加新的key,Value
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        public static void Add(string key,string value) {
            ConfigurationManager.AppSettings.Add(key,value);
        }
        /// <summary>
        /// 根据Key删除项
        /// </summary>
        /// <param name="key"></param>
        public static void Remove(string key) {
            ConfigurationManager.AppSettings.Remove(key);
        }
    }
}
